from peewee import *

host = "139.196.152.104"
db = "test"
user = "sunyuming"
passwd = "memories"

db=MySQLDatabase("test",host=host,port=3306,user=user,passwd=passwd,charset='utf8')

class BaseModel(Model):
    class Meta:
        database=db

class User(BaseModel):
    user_id=IntegerField(primary_key=True)
    mobile=CharField()
    name=CharField()

    def __str__(self):
        return "{user_id:"+str(self.user_id)+",mobile:"+self.mobile+",name:"+self.name+"}"

    class Meta:
        order_by=('user_id',)
        db_table='user'
db.connect()
if __name__ == '__main__':
    User.create_table()
    u=User.get(User.user_id==680)
    print(str(u))
